#include"main.h"
#include"class_for_draw_cub.h"

Cfor_draw_cub::Cfor_draw_cub()
{
	first=NULL;
}

int Cfor_draw_cub::add_cub(CVector3 p_pos,
					   CDirection P_for_stor,
					   CCubic* pv,
					   CCubic* pn,
					   CCubic* pb)
{
	Sfor_draw_cub* temp;
	temp=new Sfor_draw_cub;
	temp->obj.set_data(p_pos,P_for_stor,pv,pn,pb);
	temp->next=first;
	first=temp;
	return true;
}

int Cfor_draw_cub::del_cub(Sfor_draw_cub* fordel)
{
	Sfor_draw_cub* dvig=first;
	if(dvig==fordel)
	{
		first=first->next;
		delete dvig;
		return 1;
	}
	while(dvig)
	{
		if(dvig->next==fordel)
		{
			Sfor_draw_cub* fdel=dvig->next;
			dvig->next=dvig->next->next;
			delete fdel;
			return 1;
		}
		dvig=dvig->next;
	}
	return 0;
}

void Cfor_draw_cub::draw()
{
	Sfor_draw_cub* temp=first;
	while(temp)
	{
		temp->obj.draw();
		temp=temp->next;
	}
}

Sfor_draw_cub* Cfor_draw_cub::retfirst()
{
	return first;
}

Cfor_draw_cub::~Cfor_draw_cub()
{
	Sfor_draw_cub* temp=first;
	while(temp)
	{
		first=first->next;
		delete temp;
		temp=first;
	}
}